package pl.edu.agh.expert.mushrooms.gui;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

public class AnswerTableDataModel extends AbstractTableModel {
    
    private static final long serialVersionUID = 1L;
    
    private List<String> questions = new ArrayList<String>();
    private List<String> answers = new ArrayList<String>();

    @Override
    public int getRowCount() {
        return questions.size();
    }

    @Override
    public int getColumnCount() {
        return 2;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        if(columnIndex == 0) {
            return questions.get(rowIndex);
        }
        return answers.get(rowIndex);
    }
    
    public void addQuestionAnswerPair(String question, String answer) {
        questions.add(question);
        answers.add(answer);
        fireTableRowsInserted(questions.size()-1, questions.size()-1);
    }

}
